package com.lm56.web.waybill.mapper;

import com.lm56.common.MyRequestBody;
import com.lm56.web.waybill.domain.GoodsInfo;
import com.lm56.web.waybill.domain.Waybill;
import com.lm56.web.waybill.domain.WaybillTrace;
import com.lm56.web.waybill.domain.WaybillQueryParams;
import com.lm56.web.waybill.domain.WaybillTraceDTO2;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Created by Kelvin Yeung on 2016/11/3.
 */
public interface WaybillMapper {



    /**
     * 公司获取运单
     * @param companyId 必须
     * @param waybillId 可选
     * @param waybillNo 可选
     * @return
     */
    Waybill getWaybillForCompany(@Param("companyId") Long companyId,@Param("waybillId") Long waybillId,@Param("waybillNo") String waybillNo);


    /**
     * 公司获取运单详情
     * @param companyId
     * @param waybillId
     * @return
     */
    Waybill getWaybillDetailsForCompany(@Param("companyId") Long companyId,@Param("waybillId")Long waybillId);



    /**
     * 公司获取运单总数
     * @param requestBody
     * RequestBody 的startIndex,endIndex 必须
     * WaybillQueryParams 的 companyId 必须
     *              waybillNo 可选,senderPhoneNo 可选,waybillStatus 必须,isRecycle 必须
     * @return
     */
    Integer getWaybillsCountForCompany(MyRequestBody<WaybillQueryParams> requestBody);

    /**
     * 公司获取运单列表
     * @param requestBody
     * RequestBody 的startIndex,endIndex 必须
     * WaybillQueryParams 的 companyId 必须
     *              waybillNo 可选,senderPhoneNo 可选,waybillStatus 必须,isRecycle 必须
     * @return
     */
    List<Waybill> getWaybillsForCompany(MyRequestBody<WaybillQueryParams> requestBody);



    /**
     * 发货人
     * @param requestBody
     * RequestBody 的startIndex,endIndex 必须
     * WaybillQueryParams 的 senderId 必须,,isRecycle 必须
     * @return
     */
    Long getWaybillsCountForSender(MyRequestBody<WaybillQueryParams> requestBody);
    /**
     * 发货人
     * @param requestBody
     * RequestBody 的startIndex,endIndex 必须
     * WaybillQueryParams 的 senderId 必须,,isRecycle 必须
     * @return
     */
    List<Waybill> getWaybillsForSender(MyRequestBody<WaybillQueryParams> requestBody);

    /**
     * 发货人获取运单详情
     * @param senderId
     * @param waybillId
     * @return
     */
    Waybill getWaybillDetailsForSender(@Param("senderId") Long senderId,@Param("waybillId") Long waybillId);



     List<WaybillTraceDTO2> getWaybillTraceById(@Param("waybillId") Long waybillId);


     void insertWaybill(Waybill waybill);
     void insertWaybillCompany(Waybill waybill);
     void insertWaybillGoods(List<GoodsInfo> goodsInfos);
     void updateWaybill(Waybill waybill);
     void updateWaybillCompany(Waybill waybill);
     void deleteWaybillGoodsByWaybillId(long waybillId);





    /**
     * 插入运单跟踪数据
     *
     */
     void insertWaybillTrace(WaybillTrace waybillTrace);


    /**
     * 更新waybillCompany
     */
     void updateWaybillCompanyStatus(Waybill wb);

    /**
     * 这个状态是订单整体状态
     */
     void updateWaybillStatus(@Param("waybillId") Long waybillId,@Param("waybillStatus") Integer waybillStatus);
    /**
     * 更新waybill的Is_Recycle回收站标志
     */
     void updateWaybillRecycleInd(Waybill wb);
    /**
     * 批量更新waybill的Is_Recycle回收站标志
     */
     void updateWaybillsRecycleInd(@Param("companyId") Long companyId,@Param("waybillIds") List<Long> waybillIds,@Param("isRecycle") int isRecycle);
     void updateWaybillsRecycleIndForSender(@Param("senderId") Long senderId,@Param("waybillIds") List<Long> waybillIds,@Param("isRecycle") int isRecycle);

}
